# Author: Br. Francis Therese Krautter -- br.ftherese(at)gmail.com

# Allows you to search the computational engine WolframAlpha - since you have to pay for their api, this parses the HTML returned to grab limited information from the <img> and <h2> elements.

# TODO: figure out how to get around the fact that the parser barfs on the http addresses created by wolframalpha - They have been removed to avoid confusion. 

package cringer::wolframalpha;

# wolframalpha.pm
# provides search functionality for cringer using WolframAlpha

our $VERSION = '2.0';

sub said{
 my $self = $_[0];
 my $args = $_[1];
 my $me = $self->{nick};

 unless($args->{body} =~ /^wolfram: ?(.*)$/){ # if this isn't a wolfram query, we skip it.
  return;
 }
 my $wolfdata = $1;
 my $orgdata = $1;
 $wolfdata =~ s/ /+/g;
 my @r;
 @r = `./htext.pl $orgdata`;

 push(@r, qq~wolfram alpha results for "$orgdata" at http://www.wolframalpha.com/input/?i=$wolfdata~);
return @r;}
